# coding: utf-8
# 用来创建数据库模型
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime
import sys

app = Flask(__name__)
app.config.from_pyfile('/data/mngsSYS/b/app/config.py')
db = SQLAlchemy(app)

class RunJob(db.Model):
    __tabname__ = 'runjob'
    id = db.Column(db.Integer, primary_key=True)
    laboratory = db.Column(db.String(8), index=True)
    date = db.Column(db.Date, index=True)
    jobid = db.Column(db.String(64), index=True)
    status = db.Column(db.String(32), index=True, default="尚未运行")
    addtime = db.Column(db.DateTime, index=True, default=datetime.now)

if __name__ == '__main__':
    rj = RunJob.query.filter(RunJob.jobid==sys.argv[1]).first()
    rj.status = '运行完成'
    db.session.commit()
